package org.smart4j.framework.test;

/**
 * Created by lenovo on 2015/11/18.
 */
public class SequenceB implements Sequence{

    private static ThreadLocal<Integer> numberContainer = new ThreadLocal<Integer>(){
        @Override
        protected Integer initialValue() {
            return 0;
        }
    };


    @Override
    public int getNumber() {
        numberContainer.set(numberContainer.get()+1);
        return numberContainer.get();
    }

    public static void main(String[] args){
        Sequence sequence = new SequenceB();

        ChildThread thread1 = new ChildThread(sequence);
        ChildThread thread2 = new ChildThread(sequence);
        ChildThread thread3 = new ChildThread(sequence);

        thread1.start();
        thread2.start();
        thread3.start();
    }
}
